package com.bjpowernode.crm.settings.service;

import com.bjpowernode.crm.settings.domain.DicType;
import com.bjpowernode.crm.settings.mapper.DicTypeMapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName:DicTypeServiceImpl
 * Package:com.bjpowernode.crm.settings.service
 * Date:2022/6/3 16:41
 * Description:
 * Author:zsm@zhangshuming.com
 */
@Service
public class DicTypeServiceImpl implements DicTypeService {
    @Autowired
    private DicTypeMapper dicTypeMapper;
    @Override
    public List<DicType> queryAllDicType() {
        return dicTypeMapper.queryAllDicType();
    }

    @Override
    public DicType checkCode(String code) {
        return dicTypeMapper.selectByPrimaryKey(code);
    }

    @Override
    public int saveCreateDicTyped(DicType dicType) {
        return dicTypeMapper.insertSelective(dicType);
    }

    @Override
    public DicType queryDicTypeByCode(String code) {
        return dicTypeMapper.selectByPrimaryKey(code);
    }

    @Override
    public int updateEditDicTyped(DicType dicType) {
        return dicTypeMapper.updateByPrimaryKeySelective(dicType);
    }

    @Override
    public int deleteDicType(String[] codes) {
        for (int i = 0; i < codes.length; i++) {
            String code = codes[i];
            dicTypeMapper.deleteByPrimaryKey(code);
        }
        return codes.length;
    }
}

